From: Joey Hess Date: Mon, 22 Sep 2025 14:54:16 +0000 (-0400) Subject: enableremote: Disallow using type= to attempt to change the type of an existing remote X-Git-Tag: archive/raspbian/10.20251029-1+rpi1~1^2~3^2~84 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=dfbf76e2ca50d31eca6dee253c5bf3c892301463;p=git-annex.git enableremote: Disallow using type= to attempt to change the type of an existing remote Changing the type out from under an existing special remote exposes the existing config to something that may interpret it wildly differently. As seen in the bug report, this can even result in behavior that makes git-annex say it's buggy. So prevent the user from doing this. --sameas is the better way. Sponsored-by: Kevin Mueller --- diff --git a/CHANGELOG b/CHANGELOG index acb06c4485..530a560e34 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,8 @@ git-annex (10.20250829) UNRELEASED; urgency=medium and a repository in the directory got removed. * Added annex.assistant.allowunlocked config. * Add git-remote-p2p-annex and git-remote-tor-annex to standalone builds. + * enableremote: Disallow using type= to attempt to change the type of an + existing remote. -- Joey Hess Fri, 29 Aug 2025 12:34:06 -0400 diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs index 3aeae7147e..875231d458 100644 --- a/Command/EnableRemote.hs +++ b/Command/EnableRemote.hs @@ -59,8 +59,11 @@ start _ [] = unknownNameError "Specify the remote to enable." start o (name:rest) = go =<< filter matchingname <$> Annex.getGitRemotes where matchingname r = Git.remoteName r == Just name - go [] = deadLast name $ - startSpecialRemote o name (Logs.Remote.keyValToConfig Proposed rest) + go [] = deadLast name $ + let config = Logs.Remote.keyValToConfig Proposed rest + in case M.lookup SpecialRemote.typeField config of + Nothing -> startSpecialRemote o name config + Just _ -> giveup "Cannot change type= of existing special remote. Instead, use: git-annex initremote --sameas" go (r:_) | not (null rest) = go [] | otherwise = do diff --git a/doc/bugs/enableremote_type__61__rclone_on_existing_remote_crash.mdwn b/doc/bugs/enableremote_type__61__rclone_on_existing_remote_crash.mdwn index 21a7c72cb6..0fd5af8a1f 100644 --- a/doc/bugs/enableremote_type__61__rclone_on_existing_remote_crash.mdwn +++ b/doc/bugs/enableremote_type__61__rclone_on_existing_remote_crash.mdwn @@ -40,3 +40,6 @@ Using the standalone amd64 build on Debian 12. ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders) I use git-annex for "everything". I have somewhere along the lines of 14TiB stored in various git-annex repositories, synced in various degrees to anywhere between 3 and 10 hosts, with repos dating back to 2012. It's awesome. + +> [[fixed|done]] the git-annex bug by providing a better error message when +> this is attempted. --[[Joey]]